//
//  MyMoviewCollectionViewController.m
//  豆瓣zlw
//
//  Created by lanou3g on 16/1/11.
//  Copyright © 2016年 zlw. All rights reserved.
//

#import "MyMoviewCollectionViewController.h"
#import "MineViewControl.h"
#import "Moive_Data.h"
#import "MovieDetaModel.h"
#import "MoivedeetaViewController.h"
#import "Mine_Movie_ViewController.h"

@interface MyMoviewCollectionViewController ()<UITableViewDataSource,UITableViewDelegate>
{
   NSMutableArray *arrAllData;
}

@end

@implementation MyMoviewCollectionViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    [self setData];
    self.tableView.delegate=self;
    self.tableView.dataSource=self;

    self.title=@"我的电影";
    [self.HUD hide:YES];
    // Do any additional setup after loading the view.
}
-(void)setData
{
    //打开数据库
    [[Moive_Data shareMoiveData] openMoiveData];
 
    //查询数据
    arrAllData=[[Moive_Data shareMoiveData] selectAllMoive];
    //关闭数据库
    [[Moive_Data shareMoiveData] closeMoiveData];
    [self.tableView reloadData];
    
}
//*****************************实现代理的方法***********************
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [arrAllData count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *fielPath=@"cell_id";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:fielPath];
    if (cell == nil)
    {
        cell=[[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleSubtitle) reuseIdentifier:fielPath];
    }
    MovieDetaModel *model=arrAllData[indexPath.row];
    cell.textLabel.text=model.tile;
    return cell;
}
#pragma mark---------------------点击事件------------------------------
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    Mine_Movie_ViewController *VC=[[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"Min_Deta"];
    MovieDetaModel *model=arrAllData[indexPath.row];
    VC.getmodelDeta=model;
    NSLog(@"____________________________________________%@",model);
    [self.navigationController pushViewController:VC animated:YES];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
